<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title></title>
  <script src="https://cdn.bootcss.com/react/16.4.0/umd/react.development.js"></script>
  <script src="https://cdn.bootcss.com/react-dom/16.4.0/umd/react-dom.development.js"></script>
  <script src="https://cdn.bootcss.com/babel-standalone/6.26.0/babel.min.js"></script>
</head>

<body>
  <div id="root">

  </div>
</body>

</html>

<script type="text/babel">
	class MyComponent extends React.Component {
		constructor(props) {
			super(props);
			this.handleClick = this.handleClick.bind(this);
		}
		handleClick() {
			this.refs.myTextInput.focus();
		}
		render() {
			return (
				<div>
					<input type="text" ref="myTextInput" />
					<input type="button" value="获取焦点" onClick={this.handleClick} />
				</div>
			)
		}
}

ReactDOM.render(
	<MyComponent />,
	document.getElementById('root')
);
</script>